/**
 * Created by Administrator on 2016/6/30 0030.
 */
import React from 'react';

var scope;
var buyGoods;
export default class GoodsInfo extends React.Component {
    constructor(props) {
        super(props);
        scope = this;
        buyGoods = scope.props.data;
    };

    render(){
        return(
            <div className="pay-part">
                <div className="part-head">商品信息</div>
                {this.goodsInfoItems()}
            </div>
        );
    };

    goodsInfoItems(){
        var items = '';
        var goodsList = buyGoods.orderGoods;
        if(goodsList && goodsList.length > 0){
            items = goodsList.map(function (item) {
                return (
                    <li key={item.goods_id + '_goods'}>
                        <div className="info-left">
                            <img className="goods-img" src={item.goods_thumb} alt={item.goods_name} />
                            <div className="goods-name-spec">
                                <div className="goods-name">
                                    {item.gc_name}
                                    {item.act_name ? <img src="images/chaozhigou.png" alt="超值购icon"/> : ''}
                                </div>
                                <div className="goods-spec">规格：<span>{item.spec_desc}</span></div>
                            </div>
                        </div>
                        <div className="info-right">
                            <div className="goods-price">RMB<span>{item.sale_price}</span></div>
                            <div className="buy-number">&times;<span>{item.goods_num}</span></div>
                        </div>
                        {item.yhg_goods && item.yhg_goods.length > 0 ? scope.activityGoodsItem(item.yhg_goods) : ''}
                    </li>
                );
            })
        }

        return (
            <ul className="order-goods">
                {items}
            </ul>
        );
    };

    activityGoodsItem(activityGoodsItems){

        return activityGoodsItems.map(function(activityGoods){
            return (
                <div className="activity">
                    <div className="info-left">
                        <img className="goods-img" src={activityGoods.gc_thumb} alt={activityGoods.goods_name} />
                        <div className="goods-name-spec">
                            <div className="goods-name">
                                {activityGoods.gc_name}
                                <img src="images/chaozhigou.png" alt="超值购icon"/>
                            </div>
                            <div className="goods-spec">规格：<span>{activityGoods.spec_desc}</span></div>
                        </div>
                    </div>
                    <div className="info-right">
                        <div className="goods-price">RMB<span>{activityGoods.add_price}</span></div>
                        <div className="buy-number">&times;<span>{activityGoods.yhg_goods_num}</span></div>
                    </div>
                </div>
            );
        });
    };
}